<?php
	header("Content-Type: text/html;charset=utf-8");
	include("../_judge.php");
	include("../../function/function.php");
	
	$keys = chkstr(trim($_REQUEST['keys']));
	$travel_bigclass = chkstr(trim($_REQUEST['travel_bigclass']));
	$news_language = chkstr(trim($_REQUEST['news_language']));
	$records = chkstr(trim($_REQUEST['records']));
	$page = chkstr(trim($_REQUEST['page']));
	$timestart = chkstr(trim($_REQUEST['timestart']));
	$timeend = chkstr(trim($_REQUEST['timeend']));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?= $adminweb_titles ?></title>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script>if (top.location != parent.location||self.location==top.location){top.location.replace('../login/admin.php')}</script>
<script language="javascript" src="../script/jquery-1.7.2.min.js"></script>
<script language="javascript" src="../script/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="../script/weebox/bgiframe.js"></script>
<script type="text/javascript" src="../script/weebox/weebox.js"></script>
<link type="text/css" rel="stylesheet" href="../script/weebox/weebox.css" />
<script language="javascript">
$(document).ready(function(){
	$(".newswin").click(function(){
		Nids=$(this).attr("msg")
		$.weeboxs.open("newsview.php?id="+Nids+"&rnds="+ Math.random(),{
			title: '信息查看',
			contentType:'ajax',
			width:800,
			height:500,
			//contentType:'iframe',
			showButton:false,
			modal: true,
			draggable: true
			
		});
	});
	
	$(".orderwin").click(function(){
		Nids=$(this).attr("msg")
		$.weeboxs.open("newsorderm.php?id="+Nids+"&rnds="+ Math.random(),{
			title: '顺位调整',
			contentType:'ajax',
			width:300,
			height:70,
			//contentType:'iframe',
			showButton:false,
			modal: true,
			draggable: true
			
		});
	});
	
	

	$("#ckall").click(function(){
		if(this.checked){
			$("input[name='newsid[]']").attr('checked', true)  
		}else{   
			$("input[name='newsid[]']").attr('checked', false)  
		}   
	});
	
});
	function del(){
		if (!confirm("您确定要执行此操作吗？")) return false;
	}
</script>
</head>

<body>

<table width="97%" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr>
    <td><strong>后台管理</strong>&nbsp;-&nbsp;<span class="hong"><strong>游记管理</strong></span></td>
  </tr>
</table>
<form action="newsmanage.php" method="get" name="searchForm" id="searchForm">
<table width="97%" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#336699">
  <tr>
    <td><span class="bai12">搜索：</span>
      <input name="keys" type="text" id="keys" value="<?= $keys ?>" />
      <select id="travel_bigclass" name="travel_bigclass">
		<option value="">==请选择类别==</option>
		<?php
			$bigIDs = 115;
			getSoonClass_option($bigIDs,'',$travel_bigclass,3); // 下拉option
		?>
	  </select>
	  
      <span class="bai12">发布时间：
      <input name="timestart" type="text" id="timestart" value="<?=$timestart?>" size="20" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly="" />
      </span> <span class="bai12">-</span> <span class="bai12">
      <input name="timeend" type="text" id="timeend" value="<?=$timeend?>" size="20" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly="" />
      </span>    
      <input type="submit" name="ss" value="搜 索" class="button2" /></td>
    <td align="right"><span class="bai12">每页显示：</span>
      <input name="records" type="text" id="records" value="<?php if(strlen($records)>0){echo $records;}else{echo "20";} ?>" size="10" onblur="this.value=this.value.replace(/\D/g,'')" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" />
      <span class="bai12">条</span></td>
  </tr>
</table>
</form>
<br />
<form action="newsaddsave.php?action=del" method="post" name="myform" id="myform">
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <tr bgcolor="#336699">
    <td width="40" height="25" align="center"><span class="bai12">选定</span></td>
    <td align="center"><span class="bai12">游记标题</span></td>
    <td align="center"><span class="bai12">所属类别</span></td>
    <td align="center"><span class="bai12">作者</span></td>
    <td align="center"><span class="bai12">发布时间</span></td>
    </tr>
  
  <?php
		$SQL = "";
		if(!empty($keys)){
			if(!empty($SQL)){
				$SQL = $SQL." and travel_title like '%".$keys."%'";
			}else{
				$SQL = " travel_title like '%".$keys."%'";
			}
		}
		if(!empty($travel_bigclass)){
			if(!empty($SQL)){
				$SQL = $SQL ." and travel_bigclass=$travel_bigclass";
			}else{
				$SQL = " travel_bigclass=$travel_bigclass";
			}
		}
		
		
		if(!empty($timestart) && empty($timeend)){
			if(!empty($SQL)){
				$SQL = $SQL." and travel_addtime >'$timestart'";
			}else{
				$SQL = " travel_addtime >'$timestart'";
			}
		}
		if(empty($timestart) && !empty($timeend)){
			if(!empty($SQL)){
				$SQL = $SQL." and travel_addtime <'$timeend'";
			}else{
				$SQL = " travel_addtime <'$timeend'";
			}
		}
		if(!empty($timestart) && !empty($timeend)){
			if(!empty($SQL)){
				$SQL = $SQL." and travel_addtime between '$timestart' and '$timeend'";
			}else{
				$SQL = " travel_addtime between '$timestart' and '$timeend'";
			}
		}
		
		
		

		if(strlen($records)>0){
			$pagesize = $records; //分页数量
		}else{
			$pagesize = 20; //分页数量
		}
		
		if(strlen($page) > 0){
			$pageval = $page;
			if($pageval <= 0){
				$pageval = 1;
			}
			$page = ($pageval-1)*$pagesize;
			$page .= ",";
		}
		//分页链接地址
		$url="newsmanage.php?news_language=$news_language&records=$records&keys=$keys&travel_bigclass=$travel_bigclass&timestart=$timestart&timeend=$timeend&";

		if(empty($SQL)){
			$numsql = "select * from kboy_forum_travel  order by id desc";
		}else{
			$numsql = "select * from kboy_forum_travel where ".$SQL." order by id desc";
		}

		$news_sql = $numsql." limit $page $pagesize";
		$news_nums = mysql_num_rows(mysql_query($numsql));
		$pagecount = ceil($news_nums / $pagesize);
		$news_rows = mysql_query($news_sql);
		$i = 1;
		while($news_rs = mysql_fetch_array($news_rows)){
?>
		  <tr bgcolor="#efefef" onMouseOver="this.style.background='#C9C9C9'" onMouseOut="this.style.background='#efefef'">
			<td height="25" align="center"><input type="checkbox" name="newsid[]" id="newsid" value="<?=$news_rs['id'] ?>" /></td>
			<td align="center"><a href="/forum_travelview.php?newsid=<?=$news_rs['id']?>" target="_blank"><?php
				 
				if(strlen($news_rs['travel_title'])>25){
					echo cutstr($news_rs['travel_title'],25);
				}else{
					echo $news_rs['travel_title'];
				}

				if(!empty($news_rs['travel_top'])){
					echo "&nbsp;<font color=\"red\">[置]</font>";
				}
//				if(!empty($news_rs['news_tui'])){
//					echo "&nbsp;<font color=\"red\">[推]</font>";
//				}
//				
				//if(substr_count($news_rs['news_subject'],'幻灯片')>0){
				//	echo "&nbsp;<font color='red'>[幻]</font>";
				//}
				//if(substr_count($news_rs['news_subject'],'热点新闻')>0){
				//	echo "&nbsp;<font color='red'>[热]</font>";
				//}
			?></a></td>
			<td align="center">
			<span class="lv12">
			<?=getClassName("kboy_bigclass","bigclass_cn","id=".$news_rs['travel_bigclass'])?>
			</span>			</td>
			<td align="center" class="lv12">
			<?=getUserNickName($news_rs['uid'])?></td>
			<td align="center">
			<?=$news_rs['travel_addtime']?></td>
		  </tr>
			<?php
		}// while结束
		
		if($news_nums > 0){
			?>
		  <tr bgcolor="#efefef">
			<td height="25" colspan="5">&nbsp;
			  <input type="checkbox" name="ckall" value="ckall" id="ckall" />
			  &nbsp;全选&nbsp;
			  <select name="news_option" id="news_option">
				<option value="">请选择操作</option>
				<option value="del">删除</option>
			  </select>
			  &nbsp;
			  <input type="submit" name="submit2" value="执行" onClick="return del();" class="button2" />			</td>
		  </tr>
			<?php
		}
			?>
</table>
</form>
<form action="<?=$url?>" method="post" name="pageform" id="pageform">
<table width="90%" border="0" align="center" cellpadding="10" cellspacing="0">
    <tr>
      <td height="30" align="center">
	  <?php
			if($news_nums > $pagesize){
				if ($pageval<=1){
					$pageval=1;
					echo "首页&nbsp;&nbsp;";
				}else{
					echo "<a href=".$url."page=1>首页</a>&nbsp;&nbsp;";
				}
					if ($pageval<=1){
					echo "上一页</a>&nbsp;&nbsp;";
					}else{
					echo "<a href=".$url."page=".($pageval-1).">上一页</a>&nbsp;&nbsp;";
					}
					
					if ($pageval>=$pagecount){
					echo "下一页&nbsp;&nbsp;";
					}else{
					echo "<a href=".$url."page=".($pageval+1).">下一页</a>&nbsp;&nbsp;";
					}
					if($pageval<$pagecount){
					echo "<a href=".$url."page=".$pagecount.">末页</a>&nbsp;&nbsp;";
					}else{
					echo "末页&nbsp;&nbsp;";
					}
					
					echo "共&nbsp;<font color='red'>".$news_nums."</font>&nbsp;条文章&nbsp;&nbsp;";
					echo "页次：<font color='red'>".$pageval."&nbsp;/&nbsp;</font>".$pagecount."&nbsp;页&nbsp;&nbsp;";
					echo "转到：<select name='page' onChange='javascript:document.pageform.submit()'>";
					for($i=1;$i<=$pagecount;$i++){
						if($i==$pageval){
							$selectval="selected";
						}
						echo "<option value=".$i." ".$selectval.">".$i."</option>";
						$selectval="";
					}
					echo "</select>";
						
			}
	?>
      </td>
    </tr>
</table>
</form>
</body>
</html>
